<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <title>Protótipo TCC</title>
        <link rel="stylesheet" type="text/css" href="css1.css" />
        <script language="javascript">
            function getfileextension(inputId)
            {
                var fileinput = document.getElementById("xmlDataFile");
                if(!fileinput ) return "";
                var filename = fileinput.value;
                if( filename.length == 0 ) return "";
                var dot = filename.lastIndexOf(".");
                if( dot == -1 ) return "";
                var extension = filename.substr(dot,filename.length);
                return extension;
            }
            
            function checkfileType(inputId,allowedExt,allowedExt2)
            {
                var ext = getfileextension(inputId);
                if( ext == allowedExt || ext == allowedExt2){
                    //alert("ok");
                    document.forms["mainForm"].submit();
                }
                else{
                    alert("Voce deve escolher um arquivo .xml");
                    document.getElementById("xmlDataFile").value="";
                    document.getElementById("xmlDataFile").focus();
                }
                
                return false;
            }
        </script>

    </head>
    <body>

        <form name="mainForm" action="HealthSampleServlet"
              enctype="multipart/form-data" method="post">
            <h1>Uma proposta de uso do Prontuário Eletrônico Pessoal:<br>
            integrando sistemas médicos ao Google Health</h1>

            <div id="div-xmlDataFile">
            <input id="xmlDataFile" type="file" name="datafile" size="40">            
            </div>
            <div id="div-confirmButton">
                <input id="confirmButton" type="button" value="Confirmar"
                       onClick='checkfileType("xmlDataFile",".XML",".xml")'>
            </div>

        </form>
        
    </body>
</html>
